home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/exec.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "dh1:source/doors/romconf/doorheader.h"
- #define sm sendmessage
- #define pm prompt
- #define hk hotkey
- #define gu getuserstring
- #define pu putuserstring
-
- #define ACCESS_WRITE -1L
- #define ACCESS_READ -2L
- char Name[200];
- int FindIt(char *str,char *FileName);
- void Prepare();
- void GiveIt(char *Name,int opt,char *InputName,char *OutPutName);
- #define TX(x) (UBYTE)Number.Text[x]
- int PurgeIt(char *str,char *FileName,char *NewName);
-
- long lock=NULL;
- struct REGIT
- {
- char Text[8];
- long chksum;
- };
- struct REGIT Number;
- void end();
- extern int TLock(char *str);
- void sr(char *str);
- void end()
- {
- if(lock)
- UnLock(lock);
- exit(0);
- }
- char t[200];
- main(int argc,char *argv[])
- {
-
- if(argc!=2)
- {
- printf("AutoRegister 1.2, written by Joseph Hodge\n");
- printf("This is an AmiExpress 2.0+(XIM)\n");
- printf("\n\n");
- exit(0);
- }
- Register(argv[1][0]-'0');
- sm("",1);
- sm("AutoRegister 1.2, written by Joseph Hodge",1);
- sm("",1);
- if(!(lock=Lock("REGISTERED:Lockme",ACCESS_WRITE)))
- {
- sm("",1);
- sm("Sorry but an Update is currently being give on another node",1);
- sm("Please try again in a few minutes",1);
- ShutDown();
- end();
- }
-
- gu(Name,DT_NAME);strupr(Name);
- if(!FindIt(Name,"REGISTERED:Revision.Dat"))
- {
-
- sm("",1);
- sm("Your terminal must have ANSI capability to go any further.",1);
- sm("Is your terminal configured for ANSI [Y/n]",0);
- hk(" >:",t);
- if(t[0]=='n' || t[0]=='N')
- {
- sm("No.",1);
- ShutDown();
- end();
- }
- sm("Yes.",1);
- strcpy(t,"VALIDATE");
- pu(t,RETURNCOMMAND);
- Chain("DOORS:FORMEDIT/FORMEDIT",argv[1][0]-'0',WAIT);
- strcpy(t,"");
- pu(t,RETURNCOMMAND);
- if(!FindIt(Name,"REGISTERED:Validate/Validate.db"))
- {
- sm("You must complete the validation FORM.",1);
- sm("Aborting registration.",1);
- ShutDown();
- end();
- }
-
- if(FindIt(Name,"REGISTERED:BetaTester"))
- GiveIt(Name,1,"REGISTERED:AEBeta","REGISTERED:Update.Dat");
- else
- GiveIt(Name,1,"REGISTERED:AE","REGISTERED:Update.Dat");
- if(FindIt(Name,"REGISTERED:Developers"))
- {
- sm("Records indicate you are a Developer for AmiExpress",1);
- GiveIt(Name,2,"REGISTERED:Develope.LZH",NULL);
- }
- ShutDown();
- end();
- }
- if(FindIt(Name,"REGISTERED:Developers"))
- {
- sm("Records indicate you are a Developer for AmiExpress",1);
- GiveIt(Name,2,"REGISTERED:Develope.LZH",NULL);
- }
-
-
- if(FindIt(Name,"REGISTERED:BetaTester"))
- GiveIt(Name,0,"REGISTERED:AEBETA","REGISTERED:Update.dat");
- else
- {
- if(!FindIt(Name,"REGISTERED:Update.Dat") || FindIt(Name,"REGISTERED:Distributors"))GiveIt(Name,0,"REGISTERED:AE","REGISTERED:Update.Dat");
- else
- {
-
- sm("Sorry but records indicate that you already received",1);
- sm("The latest version of AmiExpress",1);
- ShutDown();
- end();
- }
- }
- ShutDown();
- end();
- }
-
- int FindIt(char *str,char *FileName)
- {
- FILE *fi;
- char image[200];
- if(!TLock(FileName)) return(0);
- strupr(str);
- fi=fopen(FileName,"r");
- while(fgets(image,80,fi)!=NULL)
- {
- sr(image);
- strupr(image);
- if(!strcmp(image,str))
- {
- fclose(fi);
- return(1);
- }
- }
- fclose(fi);
- return(0);
- }
- int PurgeIt(char *str,char *FileName,char *NewName)
- {
- FILE *fi,*fo1,*fo2;
- char image[200];
- int returncode=0;
- if(!TLock(FileName)) return(0);
- sprintf(image,"%s.tmp",FileName);
- if(!TLock(image))
- {
- Rename(FileName,image);
- }
- strupr(str);
- fi=fopen(image,"r");
- fo1=fopen(FileName,"w");
- fo2=fopen(NewName,"a");
- while(fgets(image,80,fi)!=NULL)
- {
- sr(image);
- strupr(image);
- if(!strcmp(image,str))
- {
- fprintf(fo2,"%s\n",image);
- returncode=1;
-
- }
- else fprintf(fo1,"%s\n",image);
- }
- fclose(fi);
- fclose(fo1);
- fclose(fo2);
- sprintf(image,"%s.tmp",FileName);
-
- DeleteFile(image);
- return(returncode);
- }
-
- void GiveIt(char *Name,int opt,char *InputName,char *OutPutName)
- {
- char Num[200];
- char Temp[10];
- char Test[80];
- long Position;
- char p[200];
- char TypeCode[200];
- char RegNum[200];
- long TruePosition;
- int Got=0;
- int records=0;
- int i;
- int Distributor=0;
- FILE *fi,*st;
- strcpy(t,InputName);
-
-
- if(opt==2)
- {
- sm("",1);
- if(!TLock(InputName))
- {
- sm("Please inform the Sysop that the developer package is",1);
- sm("not available.",1);
- return;
- }
- sm("Preparing Developer Package",1);
- Prepare();
- pu(t,ZMODEMSEND);
- return;
- }
- sm("AmiExpress can be released for specific machine types",1);
- sm("68000, 68030 or 68040.",1);
- if(FindIt(Name,"REGISTERED:Distributors")) Distributor=1;
- if(Distributor)
- {
- sm("Records indicate that you are a distributor.",1);
- }
- if(!Got && !opt){pm("Please Enter registration number >:",RegNum,30);
- sprintf(t,"REG:%s-%s",Name,RegNum); strupr(t);}
- if(!Distributor && !opt)
- {
- if(!PurgeIt(t,"Registered:Update.Dat","REGISTERED:Update.old"))
- {
- sm("",1);
- sm("Records indicate that this is an invalid Registration.",1);
- sm("Please leave a message with the sysop for further assistance.",1);
- sm("",1);
- ShutDown();
- end();
- }
- }
- else
- if(Distributor && !Got && !opt)
- {
- if(!FindIt(t,"Registered:Update.Dat"))
- {
- sm("",1);
- sm("Records indicate that this is an invalid Registration.",1);
- sm("Please leave a message with the sysop for further assistance.",1);
- sm("",1);
- ShutDown();
- end();
- }
- }
- while(1)
- {
- while(1)
- {
-
- sm("Please select machine type:",1);
- sm(" 1> 68000",1);
- sm(" 2> 68030",1);
- sm(" 3> 68040",1);
- if(Distributor)sm(" 4> Abort",1);
- hk(" >:",TypeCode);
- TypeCode[1]='\0';
- if(TypeCode[0]=='1'){ sm("68000.",1);sprintf(t,"%s000",InputName); break;}
- if(TypeCode[0]=='2'){ sm("68030.",1);sprintf(t,"%s030",InputName); break;}
- if(TypeCode[0]=='3'){ sm("68040.",1);sprintf(t,"%s040",InputName); break;}
- if(TypeCode[0]=='4' && Distributor) { sm("",1); break; }
-
- }
- if(TypeCode[0]=='4') break;
- if(TypeCode[0]=='1' || TypeCode[0]=='2' || TypeCode[0]=='3')
- {
- if(!records)
- {
- if(opt==1)
- {
- sm("Preparing Revision.",1);
- fi=fopen("REGISTERED:Revision.Dat","a");
- fprintf(fi,"%s\n",Name);
- fclose(fi);
- }
- records=1;
- }
- }
- strcat(t,".LZH");
- sm("",1);
- sm("Preparing main program, please standby.",1);
- if(!TLock(t))
- {
- sm("",1);
- sm("Error! Can't locate Files, please notify sysop!",1);
- sm("",1);
- ShutDown();
- end();
- }
-
- if((!Got && Distributor && opt) || !Distributor)
- {
-
- Number.chksum=time(NULL);
- st=fopen(OutPutName,"a");
- fprintf(st,"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n");
- fprintf(st,"%s\n",Name);
- fprintf(st,"CheckSum %ld ",Number.chksum);
- fprintf(st,"SumKickDate %s",ctime(&Number.chksum));
- fprintf(st,"REG:%s-%u%u%u%u%u%u%u%u%u-%u.%u%u\n",Name,TX(11),TX(1),TX(9),TX(3),TX(4),TX(8),TX(6),TX(7),TX(5),TX(2),TX(10),TX(0));
- fclose(st);
- sm("",1);
- sm("Please standby, serializing package..",1);
- sprintf(p,"%u%u%u%u%u%u%u%u%u-%u.%u%u",TX(11),TX(1),TX(9),TX(3),TX(4),TX(8),TX(6),TX(7),TX(5),TX(2),TX(10),TX(0));
- sm("Your Registration number is >:",0);
- sm(p,0);sm("",1);
- sm("****************************************************************",1);
- sm("Please record your Registration number, It will be needed to get",1);
- sm("product assistance and future updates.",1);
- sm("****************************************************************",1);
- sm("",1);
-
- }
- if(Distributor) Got=1;
- Prepare();
-
- pu(t,ZMODEMSEND);
- sm("",1); if(!Distributor) break;
-
- }
-
- sm("",1);
- /* if((records && !Distributor) || (Distributor && opt && Got))
- {
-
- }*/
- }
-
- void Prepare()
- {
- char temp[10];
- sm("",1);
- sm("Please prepare for Zmodem Download.",1);
- sm("press anykey to continue",0);
- hk("",temp);
- sm("",1);
- }
-
- void sr(char *str)
- {
- register int i;
- i=strlen(str)-1;
- while(i>-1)
- {
- if(*(str+i)<=32) *(str+i)='\0'; else break;
- i--;
- }
- }
-